<?php

function doubleArraySort($arr, $keys, $type = 'asc') {
    $keysvalue = $new_array = array();
    foreach ($arr as $k => $v){
        $keysvalue[$k] = $v[$keys];
    }
    $type == 'asc' ? asort($keysvalue) : arsort($keysvalue);
    reset($keysvalue);

    $i = 0;
    foreach ($keysvalue as $k => $v) {
       $new_array[$i] = $arr[$k];
       $i++;
    }
    return $new_array;
}